<include file="public@header"/>
<style type="text/css">

    .p_title {
        width: 515px;
        margin: 0 0 45px 60px;
        padding: 10px 0 10px 20px;
    }

    tr td input,tr td select{ max-width:100%;width:auto;}
    /*tr td input,tr td select{ max-width:80px;width:auto;}*/
    .content_nav .check_info{flex:1; display:flex;flex-direction: column;align-items: center;justify-content: center;}

    .form-control{
        /*width:100% !important; display:inline-block;*/
    }
    .free .form-group{
        margin-top: 30px;}
    .free .form-group input{
        width: 150px;}
</style>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li ><a href="{:url('finance/index')}">财务管理</a></li>
        <li class="active"><a href="">订单支付</a></li>

    </ul>
    <form class="form-horizontal  " action="{:url('orderPay')}" method="post" enctype="multipart/form-data">
        <fieldset>
            <!--改版画面-->
            <div class="div_title"><span>客户概览</span></div>
            <div class="control-group1-p div_content">
                <div class="form-group">
                    <label class="control-label ">客户姓名</label>
                    <div class="col-lg-2">
                        <input type="text"  class="form-control" value="{$customer.buyer_name}" disabled>
                    </div>
                    <label class="control-label ">持证类型</label>
                    <div class="col-lg-2" >
                        <input type="text" class="form-control" value="{:cart_type('cart',$customer.cart_type)}" disabled>
                    </div>
                    <label class="control-label ">证件号码</label>
                    <div class="col-lg-2" >
                        <input type="text"  class="form-control" value="{$customer.customer_account}" disabled>
                    </div>
                    <label class="control-label "  >联系电话</label>
                    <div class="col-lg-2">
                        <input type="text"  class="form-control" value="{$customer.buyer_phone}" disabled>
                    </div>
                </div>

                <div class="form-group" >
                    <label class="control-label ">联系地址</label>
                    <div class="col-lg-6" style="width: 41%;" >
                        <input type="text"   class="form-control"  style="width: 90%;" value="{$customer.customer_address}" disabled>
                    </div>
                    <label class="control-label w100">合同编号</label>
                    <div class="col-lg-2" >
                        <input type="text" name="user_login" class="form-control" value="{$result.contract_sn}" disabled>
                    </div>
                    <label class="control-label ">墓位编号</label>
                    <div class="col-lg-2" >
                        <input type="text" name="user_login" class="form-control" value="{$result.tomb_num}" disabled>
                    </div>
                </div>
                <div class="form-group" >
                    <label class="control-label ">具体位置</label>
                    <div class="col-lg-2" style="width: 41%;">
                        <input type="text" name="user_login" class="form-control" style="width: 90%;" value="{$result.tomb_region}" disabled>
                    </div>
                    <label class="control-label w100">当前状态</label>
                    <div class="col-lg-2">
                        <input type="text" name="user_login" class="form-control" value="{$result.pro_status}" disabled>
                    </div>
                    <label class="control-label w100" >格位规制</label>
                    <div class="col-lg-2">
                        <input type="text" name="user_login" class="form-control" value="{$result.tomb_regulation}" disabled>
                    </div>
                </div>

                <div class="row" style="margin: 0;padding: 0;" >
                    <div class="col-md-6">
                        <div class="row">
                            <div class="col-md-12" style="padding: 0 5px 10px 10px;">
                                <div class="box box-info">
                                    <div class="box-header" style="border: 2px solid #0b7ebf;overflow:hidden; overflow-x:auto;">
                                        <div class="div_title" ><span>交款记录</span></div>
                                    </div>

                                    <div class="box-body" style="padding-top:0; height: 225px; border: 2px solid #0b7ebf;overflow:hidden; overflow-x:auto;" >
                                        <table class="table table-hover table-bordered" style="max-width:120% !important;width:120% !important">
                                            <thead>
                                            <tr>
                                                <th>定金单号</th>
                                                <th>类型</th>
                                                <th>付/退款人姓名</th>
                                                <th>付/退款人时间</th>
                                                <th>金额</th>
                                                <th>付/退款人方式</th>
                                                <th>经办人</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <foreach name="deposit" item="vo">
                                                <tr>
                                                    <td >{$vo.deposit_sn}</td>
                                                    <td >{$vo.deposit_type}</td>
                                                    <td >{$vo.real_name}</td>
                                                    <td >{$vo.add_time|date='Y-m-d H:i:s'}</td>
                                                    <td >{$vo.deposit_price}</td>
                                                    <td >现金</td>
                                                    <td >{:cmf_get_admin_name($vo.handle)}</td>
                                                </tr>
                                            </foreach>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-12" style="padding: 0 5px 5px 10px;">
                                <div class="box box-info">
                                    <div class="box-header" style="border: 2px solid #0b7ebf;overflow:hidden; overflow-x:auto;">
                                        <div class="div_title" ><span>结算项目</span></div>
                                    </div>
                                    <div class="box-body" style="padding-top:0; border: 2px solid #0b7ebf;overflow:hidden; overflow-x:auto;" >
                                        <div class="div_title" id="div_title" style="width:120%;   background:#DEDDDD;box-shadow: 5px -5px 3px #CFCECE inset;"><span style="color:#222;">墓穴销售</span></div>
                                        <div class="div_titleinfo" style="width:100%;display:none;">
                                            <form action="{:url('Rock/order')}" method="post">
                                                <table class="table table-hover table-bordered" style="max-width:120% !important;width:120% !important">
                                                    <thead>
                                                    <tr>
                                                        <th>墓位编号</th>
                                                        <th>类型</th>
                                                        <th>流程</th>
                                                        <th>单位</th>
                                                        <th>数量</th>
                                                        <th>价格</th>
                                                        <th>下单时间</th>
                                                        <th>导购员</th>
                                                        <th>代理商</th>
                                                        <th>抵顶人</th>
                                                    </tr>
                                                    </thead>
                                                    <tbody>
                                                    <tr>
                                                        <td >{$result.tomb_num}</td>
                                                        <td >{$result.tomb_type}</td>
                                                        <td >  <if condition=" $result.tomb_num eq 0">购买 <else/>寄存 </if></td>
                                                        <td >平米</td>
                                                        <td >{$result.subscription_area}</td>
                                                        <td >{$result.selling_price}</td>
                                                        <td >暂时均不显示</td>
                                                        <td >{:cmf_get_admin_name($result.shoppingguide)}</td>
                                                        <td >{:cmf_get_admin_name($result.agent_user)}</td>
                                                        <td >{$result.reacher}</td>
                                                    </tr>

                                                    </tbody>
                                                </table>
                                            </form>
                                        </div>
                                        <div class="div_title" id="div_title1" style="width:120%; background:#DEDDDD;box-shadow:5px -5px 3px #CFCECE inset;"><span style="color:#222;">商品销售</span></div>
                                        <div class="div_titleinfo1 disappear">
                                                <table class="table table-hover table-bordered" style="max-width:120% !important;width:120% !important">
                                                    <thead>
                                                    <tr>
                                                        <th>序号</th>
                                                        <th>项目名称</th>
                                                        <th>大类</th>
                                                        <th>类型</th>
                                                        <th>单位</th>
                                                        <th>单价</th>
                                                        <th>数量</th>
                                                        <th>优惠</th>
                                                        <th>销售</th>
                                                        <th>合计</th>
                                                    </tr>
                                                    </thead>
                                                    <tbody>
                                                    <foreach name="goods_arr" item="vos">
                                                        <tr>
                                                            <td >{$key+1}</td>
                                                            <td >{$vos.goods_name}</td>
                                                            <td >{$vos.cate_name}</td>
                                                            <td > </td>
                                                            <td > </td>
                                                            <td >{$vos.goods_price}</td>
                                                            <td >{$vos.num}</td>
                                                            <td >{$vos.discount_price}</td>
                                                            <td >{$vos.add_user}</td>
                                                            <td >{$vos.total_price}</td>
                                                        </tr>
                                                    </foreach>
                                                    </tbody>
                                                </table>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-6 free">
                        <div class="box box-info">
                            <div class="box-header" style="border: 2px solid #0b7ebf;overflow:hidden; overflow-x:auto;">
                                <div class="div_title" ><span>费用信息</span></div>
                            </div>
                            <div class="box-body" style="padding-top:0; border: 2px solid #0b7ebf;overflow:hidden; overflow-x:auto;" >
                                <div class="form-group" >
                                    <label class="control-label">销售合计</label>
                                    <div class="col-lg-3" >
                                        <input type="hidden" name="tom_price" class="form-control " value="{$result.sales_total}"  >
                                        <input type="text"   class="form-control" value="{$result.sales_total}" disabled>%
                                    </div>
                                    <label class="control-label">优惠金额</label>
                                    <div class="col-lg-3" >
                                        <input type="text" id="discount_ratio"    disabled class="form-control" >
                                        <input type="hidden" id="discount_ratio_" name="discount_rate" value="{$result.discount_ratio}" >
                                    </div>
                                </div>
                                <div class="form-group" >
                                    <label class="control-label">购墓合计</label>
                                    <div class="col-lg-3" >
                                        <input type="text"   class="form-control"  value="{$result.total_price}" disabled>
                                        <input type="hidden" name="total_price"   value="{$result.total_price}" >元
                                    </div>
                                    <label class="control-label">减免金额</label>
                                    <div class="col-lg-3" >
                                        <input type="hidden" name="free_price" value="{$result.free_price}" >
                                        <input type="text" disabled  class="form-control"  value="{$result.free_price}" >元
                                    </div>
                                </div>
                                <div class="form-group" >
                                    <label class="control-label">另收费项目</label>
                                    <div class="col-lg-3" >
                                        <input type="hidden"  name="pay_service_price"   value=" {$result.pay_service_price}"  >
                                        <input type="text"  class="form-control pay_service_price"  value="￥{$result.pay_service_price}" disabled>元
                                    </div>
                                    <label class="control-label" >合计应收</label>
                                    <div class="col-lg-3" >
                                        <input type="hidden"  class=" deal_price" name="deal_price"  value="{$result.closing_price}"  >
                                        <input type="text"  class="form-control deal_price_"  value="￥{$result.closing_price}" disabled>元
                                    </div>
                                </div>
                                <div class="form-group" >
                                    <label class="control-label">预付款</label>
                                    <div class="col-lg-3"  >
                                        <input type="hidden" class="deposit_price"  name="deposit_price" value="{$result.deposit_price}" >
                                        <input type="text"  class="form-control deposit_price_"  value="￥{$result.deposit_price}" disabled>元
                                    </div>
<!--                                    <label class="control-label" >二次付款</label>-->
<!--                                    <div class="col-lg-3" >-->
<!--                                        <input type="hidden" class="deposit_price_two"  name="deposit_price_two" value="{$result.deposit_price_two|default='0'}"  >-->
<!--                                        <input type="text"  class="form-control deposit_price_two_"  value="￥ " disabled>元-->
<!--                                    </div>-->
                                    <label class="control-label" >应收金额</label>
                                    <div class="col-lg-3" >
                                        <input type="hidden" class="total_price"  name="total_price" value=" " >
                                        <input type="text"  class="form-control total_price_" value=""   disabled>元
                                    </div>
                                </div>
                                <div class="form-group" >
                                    <label class="control-label" >付款人</label>
                                    <div class="col-lg-3" >
                                        <input type="text"  name="real_name" class="form-control"  value="{$pay_info.real_name}">
                                    </div>
                                    <label class="control-label">付款人联系电话</label>
                                    <div class="col-lg-3" style=" ">
                                        <input type="text"  name="real_phone" class="form-control"  value="{$pay_info.real_phone}">
                                    </div>
                                </div>
                                <div style="float:left; width:90%; margin-left:6%;border-bottom:1px dashed;margin-bottom:20px;"></div>
                                <div class="form-group" >
                                        <label class="control-label" style="">商品总计</label>
                                        <div class="col-lg-3" >
                                            <input type="hidden" class="goods_price" name="goods_price"  value="{$pay_info.goods_price}">
                                            <input type="text" class="form-control goods_price_"  value="￥{$pay_info.goods_price}" disabled>元
                                        </div>
                                    <label class="control-label" >付款方式</label>
                                    <div class="col-lg-3"  >
                                        <select name="pay_type"   class="form-control">
                                            <option value="1">现金</option>
                                            <option value="2">转账</option>
                                            <option value="3">电汇</option>
                                            <option value="4">微信</option>
                                            <option value="5">支付宝</option>
                                            <option value="6">其他</option>
                                        </select>
                                    </div>
                                </div>
                                <div style="float:left; width:90%; margin-left:6%;border-bottom:1px dashed;margin-bottom:20px;"></div>

                                <div class="form-group" >
                                    <label class="control-label">收银备注</label>
                                    <div class="col-lg-7" style=" ">
                                        <textarea rows="3" name="remark" style="width: 90%" class="form-control" ></textarea>
                                    </div>
                                </div>
                                <div class="form-group" >
                                    <label class="control-label" >付款时间</label>
                                    <div class="col-lg-3" >
                                        <input type="text" name="add_time" class="form-control js-date" disabled  value='{$result.payaddtime}'>
                                    </div>
                                    <label class="control-label" style="">收款人</label>
                                    <div class="col-lg-3" >
                                        <input type="text"   class="form-control"  value="{:cmf_get_admin_name()}" disabled>
                                    </div>
                                </div>

                                <div class="form-group" >
                                    <div class="col-lg-12" >
                                        <label class="control-label" style=""> </label>
                                        <input type="hidden"  name="tomb_type"   value="2">
                                        <input type="hidden" id="dtype"  name="dtype" value="js">
                                        <input type="hidden" id="order_id" name="order_id" value="{$result.order_id|default=''}">
                                        <input type="hidden" id="tomb_id" name="tomb_id" value="{$result.tomb_id|default=''}">
                                        <input type="hidden" name="tomb_num" value="{$result.tomb_num|default=''}">
                                        <input type="hidden" id="customer_id" name="customer_id" value="{$result.customer_id|default=''}">
                                        <input type="hidden" id="pay_id" name="pay_id" value="{$pay_info.id}">
                                        <input type="hidden" name="deposit_id" value="{$pay_info.deposit_id}">
                                        <input type="hidden" id="customer_tomb_number"   value="{$result.tomb_num}">
                                        <!--<if condition="$pay_info.status eq 0">-->
                                        <div class="btn btn-primary check-save" data-index="settlement">结账</div>
                                        <!--                                            <div class="btn btn-info check-save" data-index="refund" style="float: right;margin-right: 100px;">重置</div>-->
                                        <!--<else />-->
                                        <div class="btn btn-success check-save" data-index="sj">补打收据</div>
                                        <div class="btn btn-success check-save" data-index="mz">补打墓证</div>
                                        <!--</if>-->
                                        <div class="btn btn-info check-save" data-index="refund" style="float: right;margin-right: 100px;">重置</div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </fieldset>
    </form>
</div>
<div id="print_html" style="display: none"></div>
<script type="text/javascript" src="__STATIC__/js/lodop/LodopFuncs.js?v={:time()}"></script>
<script type="text/javascript" src="__STATIC__/js/admin.js?v={:time()}"></script>
<script type="text/javascript">
    $(function () {
        var discount_ratio_ = $('#discount_ratio_').val()*100;
        $('#discount_ratio').val(100-discount_ratio_+'折')
        //
        // $('.deposit_price_two_').val('￥'+$('.deposit_price_two').val());
        //
        var receivable_price = Number(Number($('.deal_price').val().replace(/,/g, "")).toFixed(2)*1 -
            Number($('.deposit_price').val().replace(/,/g,"")).toFixed(2)*1
            // Number($('.deposit_price_two').val().replace(/,/g,"")).toFixed(2)*1
        );
        $('.total_price').val(receivable_price);
        $('.total_price_').val('￥'+receivable_price);
    });
    $('#btn-dymz').click(function () {
        window.open('{:url("Print/muzheng")}',false);
        // window.open('{:url("Print/muzheng")}',  "n3", "height=800,width=1100");
    })

    $(".check-save").click(function(){
        var z3 = $(this),
            oid = $('#order_id').val(),
            pid = $('#pay_id').val(),
            mwid = $('#tomb_id').val(),
            customer_tomb_number = $('#customer_tomb_number').val(),
            cid = $('#customer_id').val()
        z4 = z3.parent();
        if (z3.data('index') == 'refund') {
            $("#dtype").val('rt');
            layer.confirm("请慎重操作，确认后将会清除该墓位所有的填写数据！", {
                icon: 3,
                title: "提示", btn: ['确定', '没有']
                , btn1: function () {
                    $.post($(".form-horizontal").attr('action'), $(".form-horizontal").serialize(), function(result){
                        console.log(result)
                        if (result.code == 0) {
                            layer.alert(result.msg, { icon: 5 });
                        } else {
                            layer.confirm(result.msg, {
                                icon: 1, btn: ['确认']
                                , btn1: function () {
                                    window.location.reload()
                                }
                            });
                        }
                    }, 'json');

                }
            })
        } else if (z3.data('index') == 'settlement') {
            $("#dtype").val('js');
            layer.confirm("这笔款确定结清了吗？", {
                icon: 3,
                title: "提示", btn: ['确定', '没有']
                , btn1: function () {
                    $.ajax({
                        type: "POST", url: $(".form-horizontal").attr('action'),
                        data: $(".form-horizontal").serialize(),
                        dataType: "json", success: function (r) {
                            console.log(r)
                            if (r.code == 1) { layer.alert(r.msg, { icon: 5 }); }
                            else {
                                var L;
                                if (r.cw == "l") { L = "&l=l"; } else { L = ""; }
                                layer.confirm(r.msg, {
                                    icon: 1, btn: ['打印收据','打印墓证','关闭']
                                    , btn1: function () {
                                        $.post("{:url('ajax_print')}", {type:1,itype:1,oid:r.data.oid,mwid:r.data.mwid,pid:r.data.pid}, function(result){
                                            $.ajax({
                                                type: "get", url:result.data.url,
                                                success: function (strHtml) {
                                                    var data = strHtml.data;
                                                    console.log('打印销售单')
                                                    $('#print_html').html(data.html)
                                                    preViewPrint(data.head_title,2,data.itype)
                                                }
                                            })
                                        }, 'json');
                                    },
                                    btn2: function () {
                                        layer.open({
                                            type:1,
                                            title:'请填写墓证编号',
                                            area:['320px','150px'],
                                            content:' <input id="txtReason" style="width:100%;height:50px;resize:none;border-radius:6px;border: 0;outline: none;" value="'+customer_tomb_number+'"  placeholder="请输入墓证编号"> ',
                                            btn:['确认','取消']
                                            , yes: function (index, layero) {
                                                var closeContext= $('#txtReason').val();
                                                $.post("{:url('ajax_print')}",{type:2,itype:1,oid:oid,mwid:mwid,czrid:cid,cno:closeContext}, function(result){
                                                    console.log(result)
                                                    layer.closeAll();
                                                    localStorage.setItem("mz", JSON.stringify(result.data));
                                                    window.open("{:url('print/muzheng')}?type=1", false);
                                                }, 'json');
                                            }
                                        });
                                    } ,
                                    btn3: function () {
                                        layer.closeAll();
                                    }
                                });
                            }
                        }
                    });
                }
                , btn2: function () {
                    location.reload();
                }
            });
        }else if (z3.data('index') == 'sj'){
            layer.confirm('确定要补打收据吗？', {
                icon: 3, btn: ['是','否']
                , btn1: function () {
                    // location.reload();
                    $.post("{:url('ajax_print')}", {
                        type: 1,itype:1,
                        oid: oid,
                        mwid: mwid,
                        pid:pid
                    }, function (result) {
                        $.ajax({
                            type: "get", url:result.data.url,
                            success: function (sr) {
                                var data = sr.data;
                                console.log('打印销售单')
                                $('#print_html').html(data.html)
                                preViewPrint('销售结算单',2,data.itype)
                                layer.closeAll();
                            }
                        })
                    }, 'json');
                },
            })
        }else if (z3.data('index') == 'mz'){
            layer.confirm('确定要补打墓证吗？', {
                icon: 3, btn: ['是','否']
                , btn1: function () {
                    layer.open({
                        type:1,
                        title:'请填写墓证编号',
                        area:['320px','150px'],
                        content:' <input id="txtReason" style="width:100%;height:50px;resize:none;border-radius:6px;border: 0;outline: none;" value="'+customer_tomb_number+'"  placeholder="请输入墓证编号"> ',
                        btn:['确认','取消']
                        , yes: function (index, layero) {
                            var closeContext= $('#txtReason').val();
                            $.post("{:url('ajax_print')}",{type:2,itype:1,oid:oid,mwid:mwid,czrid:cid,cno:closeContext}, function(result){
                                console.log(result)
                                localStorage.setItem("mz", JSON.stringify(result.data));
                                layer.closeAll();
                                window.open("{:url('print/muzheng')}?type=1", false);
                            }, 'json');
                        }
                    });
                },
            })
        }
    });
    $("#div_title").click(function(){
        if($(".div_titleinfo").is(":hidden")){
            $(".div_titleinfo").show();
        }else{
            $(".div_titleinfo").hide();
        }
    })
    $("#div_title1").click(function(){
        if($(".div_titleinfo1").is(":hidden")){
            //
            $(".div_titleinfo1").show();
        }else{
            $(".div_titleinfo1").hide();
        }
    })
</script>
<script language="javascript" type="text/javascript">
    var LODOP; //声明为全局变量
</script>
<script type="text/javascript" src="__STATIC__/js/print.js?v={:time()}"></script>
</body>
</html>